package exam.day33;

import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] s = in.next().toCharArray();
        int n = s.length;
        int max = 0;
        for(int i = 0; i < n - 1; i++) {
            max = Math.max(max, count(s, i));
        }
        System.out.println(max);
    }

    public static int count(char[] s, int index) {
        char a = s[index];
        char b = s[index + 1];
        int left = index - 1;
        int right = index + 2;
        int count = 2;
        boolean flgLeft = true;
        boolean flgRight = true;
        while(left >= 0 || right < s.length) {
            if(flgLeft && left >= 0 && (s[left] == a || s[left] == b)) {
                count++;
            } else {
                flgLeft = false;
            }
            if(flgRight && right < s.length && (s[right] == a || s[right] == b)) {
                count++;
            } else {
                flgRight = false;
            }
            left--;
            right++;
            if((left < 0 || flgLeft == false) && (right >= s.length || flgRight == false)) {
                break;
            }
        }
        return count;
    }
}
